package com.beamfield.controller.manage.steelplant;

import com.beamfield.common.ApiResult;
import com.beamfield.controller.common.BaseController;
import com.beamfield.service.serviceimpl.manage.steelplant.SteelplantProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Zephyr
 * @description:
 * @date 2019/7/31
 */
@Controller
@RequestMapping("/cms/steelplant")
public class SteelplantController extends BaseController {

    @Autowired
    private SteelplantProductService steelplantProductService;

    @RequestMapping("/statistics_home")
    public ModelAndView statisticsHome(){
        return new ModelAndView();
    }

    @RequestMapping("/statistics_stock")
    public ModelAndView statisticsStock(){
        return new ModelAndView();
    }


    @RequestMapping("/getStatistics")
    @ResponseBody
    public ApiResult getStatistics(HttpServletRequest request){
        Long beamId = super.getBeamId(request);
        return steelplantProductService.getStatistics(beamId);
    }

    @RequestMapping("/getStatisticsStock")
    @ResponseBody
    public ApiResult getStatisticsStock(HttpServletRequest request){
        String suppliesName = request.getParameter("suppliesName");
        Long beamId = super.getBeamId(request);

        return steelplantProductService.getStatisticsStock(suppliesName, beamId);
    }
}
